<?php
/**
 * Created by PhpStorm.
 * User: Krystal
 * Date: 2018/9/3
 * Time: 18:16
 */

namespace app\common\validate;
use think\Validate;

/**
 * 订单验证器
 * Class Orders
 * @package app\common\validate
 */
class Orders extends Validate
{
    protected $rule = [
        'id' => 'require|gt:0',
        'type' => 'require|gt:0',
        'trade_type' => 'require|gt:0',
        'fortune_type' => 'require|gt:0',
        'gid' => 'require|gt:0',
        'gids' => 'min:1',
        'rid' => 'require|gt:0',
        'rids' => 'require|min:1',
        'time' => 'require|gt:0',
        'order_id' => 'require|length:20,22',
        'openid' => 'min:1'
    ];

    protected $message=[
        'id.require' => '课程id必须有',
        'id.gt' => '课程不存在',
        'trade_type.require'=>'缺少支付方式',
        'trade_type.gt' => '支付方式不存在',
        'gid.require'=>'缺少商品id',
        'gid.gt' => '商品不存在',
        'gids.require' => '缺少商品id',
        'gids.min' => '商品不存在',
        'rid.require' => '缺少档案id',
        'rid.gt' => '档案不存在',
        'rids.require'=>'缺少档案id',
        'rids.min' => '档案不存在',
        'time.require' => '缺少开通时间',
        'time.gt' => '时间格式违法',
        'order_id.require'=>'缺少订单编号',
        'order_id.length' => '订单编号违规',
        'openid.min' => '微信参数违规'
    ];

    protected $scene = [
        'read'=> [
            'order_id'
        ],
        'v2_pay_unlock' => [
            'trade_type',
            'gid',
            'rids',
            'time',
            'openid'
        ],
        'v4_pay_unlock' => [
            'trade_type',
            'gids',
            'rid',
            'type',
            'openid'
        ],
        'v5_pay_unlock' => [
            'trade_type',
            'fortune_type',
            'gid',
            'rids',
            'time',
            'openid'
        ],
        'v9_pay_unlock' => [
            'trade_type',
            'id',
            'openid'
        ],
        'pay_again' => [
            'trade_type',
            'order_id',
            'openid'
        ],
    ];

    protected $field=[
        'id' => '课程id',
        'type' => '地图购买方式,1=>打包,2=>不打包',
        'trade_type'=>'支付方式',
        'fortune_type' => '运势类型',
        'gid'=>'商品id',
        'gids' => '多个商品id,例如:20,21',
        'rid' => '档案id',
        'rids'=>'档案id,例如:553379,553345',
        'time' => '开通时间',
        'order_id'=>'订单编号'
    ];

}